<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:p="http://primefaces.prime.com.tr/ui">
<h:head>
	
</h:head>

<h:body>
	<ui:composition template="/template/common/commonLayout.xhtml">

		<ui:define name="content">
			<h:outputStylesheet library="css" name="holidays.css" />
			<h1 style="color: #709FB3;">Prazniki</h1>
			<div id="holidays" class="holidays">
				<h:form id="dataTableForm">
					<p:messages id="messages" />
					<table class="formTable maxWidth">
						<tr class="formRow1">
							<td class="labelCell date">
								<h:outputText value="Datum:" />
							</td>
							<td class="inputCell date">
								<p:calendar id="date" 
									value="#{holidaysController.date}"
									pattern="dd.MM.yyyy" 
									effect="slide"/>
							</td>
							<td class="labelCell description">
								<h:outputText value="Opis praznika:" />
							</td>
							<td class="inputCell description">
								<h:inputText value="#{holidaysController.description}" />
							</td>
							<td class="labelCell year">
								<h:outputText value="Leto izpisa praznikov:" />
							</td>
							<td class="inputCell year">
								<h:selectOneMenu id="years" styleClass="fieldSelection" value="#{holidaysController.selectedYear}" >
									<f:selectItems
										value="#{holidaysController.getDiscreteValueProvider().getDiscreteValueSet('Years')}" />
									<f:ajax event="valueChange" listener="#{holidaysController.changeHolidays}" render="dataTableForm" /> 	
								</h:selectOneMenu>
							</td>
							<td class="labelCell empty">
							</td>
							<td class="inputCell empty">
							</td>
						</tr>
					</table>
					<div>
						<p:spacer width="100%" height="5"/>
							<p:dataTable id="holidayDataTable" var="holiday" value="#{holidaysController.holidays}" paginator="true" rows="10">
						        <p:column sortBy="#{holidaysController.sortByDate(holiday.date)}">
						            <f:facet name="header">
						                <h:outputText value="Datum" />
						            </f:facet>
						            <h:outputText value="#{holidaysController.convertDate(holiday.date)}"/>
						        </p:column>
						        <p:column sortBy="#{holiday.description}">
						            <f:facet name="header">
						                <h:outputText value="Opis" />
						            </f:facet>
						            <h:outputText value="#{holiday.description}"/>
						        </p:column>
						        <p:column>
						            <p:commandLink
										actionListener="#{holidaysController.removeHoliday(holiday)}"
										value="Odstrani"
										update="dataTableForm:holidayDataTable" />
						        </p:column>
						    </p:dataTable>
						<h:panelGrid columns="1">
							<p:spacer width="100%" height="5"/>
							<p:commandButton value="#{translatorService.translate('holidays.button.add')}" 
								actionListener="#{holidaysController.addHoliday()}" 
								update="dataTableForm"/>
						</h:panelGrid>
					</div>
				</h:form>
			</div>
		</ui:define>
	</ui:composition>
</h:body>

</html>